ABC134 C - Exception Handling
提出
TLE
code: python
n = int(input())
for i in range(n):
if (len(a1) == 0):
print(max(a2))
elif (len(a2) == 0):
print(max(a1))
else:
print(max((max(a0:i)), (max(ai+1:)))) WA
b = [i for i in a if i != max1]で重複削除してしまっている
code: python
n = int(input())
max1 = max(a)
if (len(b) != 0):
max2 = max(b)
else:
max2 = max1
for i in range(n):
print(max2)
else:
print(max1)
解答
code: python
import copy
n = int(input())
b = copy.copy(a)
b.sort(reverse=True)
for i in range(n):
print(ans)
提出
code: python
n = int(input())
# 1番目と2番目を求める
b = sorted(a, reverse=True)
for num in a:
if num == max1:
print(max2)
else:
print(max1)